﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using VLIB2D.Geometry2D;

namespace GMPP
{
    public partial class DrawPoly : Form
    {

        public List<Point2D> poly = new List<Point2D>();

        public delegate void GetPoly(List<Point2D> pts);///声明一个委托

        public   GetPoly EventPoly;///实例化一个委托，在其他地方讲其他地方的方法作为参数传入

        public DrawPoly()
        {
            InitializeComponent();
        }

        private bool _isIn = false;

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {

        }

        private void pictureBox1_MouseLeave(object sender, EventArgs e)
        {
            _isIn = false;
        }

        private void pictureBox1_MouseEnter(object sender, EventArgs e)
        {
            _isIn = true;
        }

        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            if (_isIn)
            {
                poly.Add(new Point2D(e.X, e.Y));
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            GetPoly gp = EventPoly;
            gp(poly);
            
        }


    }
}
